import { Fragment } from '@/components/Fragment';
import { Heading } from '@aws-amplify/ui-react';
import {
DefaultHeadingExample,
HeadingLevelExample,
HeadingStylePropsExample,
HeadingThemeExample,
TruncatedHeading
} from './examples';
import { HeadingDemo } from './demo';
import { Example, ExampleCode } from '@/components/Example';
import { ComponentStyleDisplay } from '@/components/ComponentStyleDisplay';
import ThemeExample from '@/components/ThemeExample.mdx';
## Demo
## Usage
Import the Heading primitive.
```jsx file=./examples/DefaultHeadingExample.tsx
```
### Heading levels
Use the `level` prop to change the heading level (e.g., `h1 - h6`). Default heading level is `6` and available options are `1`, `2`, `3`, `4`, `5` and `6`.
```jsx file=./examples/HeadingLevelExample.tsx
```
### Truncate
The `isTruncated` prop will render an ellipsis when the Heading text exceeds its allowed width.
```jsx file=./examples/TruncatedHeading.tsx
```
## CSS Styling
```tsx file=./examples/HeadingThemeExample.tsx
```
### Target classes
### Global styling
To override styling on all Headings, you can set the Amplify CSS variables or use the built-in `.amplify-heading` class.
Hello world
```css
/* styles.css */
:root {
--amplify-components-heading-color: gray;
}
/* OR */
.amplify-heading {
color: gray;
}
```
Override styles for any `Heading` component `h1 - h6` using the `.amplify-heading--[LEVEL]` classes.
Small and italic
Big and bold
```css
/* styles.css */
.amplify-heading--1 {
font-size: 1rem;
font-style: italic;
}
.amplify-heading--6 {
font-size: 2rem;
font-weight: bold;
}
```
```jsx
import './styles.css';
Small and italic
Big and bold
```
### Local styling
To override styling on a specific Heading, you can use a class selector or style props.
_Using a class selector:_
Hello world
```css
/* styles.css */
.heading-blue {
color: var(--amplify-colors-blue-80);
}
```
```jsx
import './styles.css';
Hello world
;
```
_Using style props:_
```jsx
Hello world
```